package com.weakteam.mobile.minimum.state;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by Nail Sharipov (nailxsharipov@gmail.com) on 30.10.2014.
 */
public class UserSettings {

    private static final String USER_DATA = "TAXI_MINIMUM_USER_DATA";

    private static final UserSettings instance = new UserSettings();

    private String login;
    private String password;
    private boolean savePassword;

    public static UserSettings getInstance() {
        return instance;
    }

    private UserSettings() {}

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public void save(Context context) {
        SharedPreferences settings = context.getSharedPreferences(USER_DATA, Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = settings.edit();
        editor.putString("login", this.login);
        editor.putString("password", this.password);

        editor.commit();
    }

    public void load(Activity activity) {
        SharedPreferences settings = activity.getSharedPreferences(USER_DATA, Context.MODE_PRIVATE);
        this.login = settings.getString("login", "");
        this.password = settings.getString("password", "");
    }

}
